#include <lpc23xx.h>
#include "LCD.h"
void RTC_isr(void)  __irq;
unsigned int flasher = 0x0000000; 	
int main (void)
{
    
unsigned int delay; //
	    lcd_init();					   //
	lcd_clear();				  //
	set_cursor(2,0);			   // Agaf=/
    lcd_print("RTC Example");	 //
    				
FIO2DIR=0x000000FF;  
   
RTC_CCR             = 0x00000000;                       //Clear the clock control register
RTC_CIIR			= 0x00000001;						//Enable seconds counter interrupt
RTC_SEC				= 0x00000000;
RTC_ALSEC			= 0x00000003;						//Set alarm register for 3 seconds
RTC_AMR				= 0x000000FE;						//Enable seconds Alarm
RTC_CCR 			|= 0x1 |   0x1<<4;    						  //Start the RTC
                     //Select the external RTC crystal
          
VICVectAddr13 	= (unsigned)RTC_isr; 				//Set the timer ISR vector address
VICVectCntl13 	= 0x0000000F;						//Set channel
VICIntEnable 	  = 0x00002000;						//Enable the interrupt



while(1)
{
FIO2CLR=0xFF;;
}

}




void RTC_isr(void)__irq	   
{


if(RTC_ILR&0x00000001)									//Test for RTC counter interrupt
{
	
	FIO2SET 		= 0x00000010;						//Set the idle LED
	RTC_ILR 		= 0x00000001;						//Clear the interrupt register
}

if(RTC_ILR & 0x00000002)
{
	FIO2SET 		= 0x00000001;						//Set LED 0.7
	RTC_ILR 		= 0x00000002;
}
VICVectAddr 	= 0x00000000;						//Dummy write to signal end of interrupt
}